package web;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PDFCtrl;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice.ThemeType;

@Controller
public class OpenPDF extends HttpServlet{
	private static final long serialVersionUID = -758686623642845302L;
	
	@RequestMapping("openpdf")  
    public String openpdf(HttpServletRequest request, HttpServletResponse response){
		// 按键说明：光标键、Home、End、PageUp、PageDown可用来移动或翻页；数字键盘+、-用来放大缩小；数字键盘/、*用来旋转页面。
		PDFCtrl pdfCtrl = new PDFCtrl(request);//定义PDFCtrl控件对象
		pdfCtrl.setServerPage(request.getContextPath()+"/poserver.zz"); //设置服务器页面
		pdfCtrl.setTheme(ThemeType.CustomStyle);//设置主题样式

		//添加自定义按钮
		pdfCtrl.addCustomToolButton("打印", "Print()", 6);
		pdfCtrl.addCustomToolButton("-", "", 0);
		pdfCtrl.addCustomToolButton("实际大小", "SetPageReal()", 16);
		pdfCtrl.addCustomToolButton("适合页面", "SetPageFit()", 17);
		pdfCtrl.addCustomToolButton("适合宽度", "SetPageWidth()", 18);
		pdfCtrl.addCustomToolButton("-", "", 0);
		pdfCtrl.addCustomToolButton("首页", "FirstPage()", 8);
		pdfCtrl.addCustomToolButton("上一页", "PreviousPage()", 9);
		pdfCtrl.addCustomToolButton("下一页", "NextPage()", 10);
		pdfCtrl.addCustomToolButton("尾页", "LastPage()", 11);
		pdfCtrl.addCustomToolButton("-", "", 0);
		pdfCtrl.addCustomToolButton("左转", "RotateLeft()", 12);
		pdfCtrl.addCustomToolButton("右转", "RotateRight()", 13);
		pdfCtrl.addCustomToolButton("-", "", 0);
		pdfCtrl.addCustomToolButton("放大", "ZoomIn()", 14);
		pdfCtrl.addCustomToolButton("缩小", "ZoomOut()", 15);
		pdfCtrl.addCustomToolButton("-", "", 0);
		pdfCtrl.addCustomToolButton("全屏", "SwitchFullScreen()", 4);
		//设置禁止拷贝
		pdfCtrl.setAllowCopy(false);

		String fileName = request.getParameter("fileName");//定义文件名称
		pdfCtrl.webOpen("doc/" + fileName);//打开文件
		pdfCtrl.setTagId("PDFCtrl1");
		return "OpenPDF";
    }
	
}
